<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="../../assets/css/layui.css">
    <link rel="stylesheet" href="../../assets/css/view.css"/>
    <title></title>
</head>
<body class="layui-view-body">
    <div class="layui-content">
        <div class="layui-row">
            <div class="layui-card">
                <div class="layui-card-header">录入快件</div>
                <form id="form" class="layui-form layui-card-body">
                  <div class="layui-form-item">
                    <label class="layui-form-label">单号</label>
                    <div class="layui-input-block">
                      <input type="text" name="code" required  lay-verify="required" placeholder="请输入快递单号" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">快递公司</label>
                    <div class="layui-input-block">
                      <select name="company" lay-verify="" lay-search>
						<option >安能快递</option><option >安能物流</option><option >澳大利亚邮政</option><option >阿根廷邮政</option><option >爱沙尼亚邮政</option><option >阿联酋邮政</option><option >奥地利邮政</option><option >阿尔巴尼亚邮政</option><option >Aramex</option><option >巴西邮政</option><option >比利时邮政</option><option >百世快运</option><option >波兰邮政</option><option >白俄罗斯邮政</option><option >保加利亚邮政</option><option >巴基斯坦邮政</option><option >百福东方</option><option >包裹信件</option><option >晟邦物流</option><option >城市100</option><option >City-Link</option><option >COE</option><option >传喜物流</option><option >德邦快递</option><option >大田物流</option><option >递四方</option><option >DHL德国</option><option >DHL全球</option><option >DHL中国</option><option >EMS</option><option >EMS国际</option><option >EMS经济快递</option><option >FedEx中国</option><option >FedEx国际</option><option >FedEx美国</option><option >飞豹快递</option><option >凡宇快递</option><option >飞远配送</option><option >飞远(爱彼西)</option><option >法国邮政</option><option >芬兰邮政</option><option >国通快递</option><option >postco</option><option >百世快递</option><option >恒路物流</option><option >黄马甲配送</option><option >黑猫宅急便</option><option >华企快运</option><option >韩国邮政</option><option >佳吉快运</option><option >京东快递</option><option>佳怡物流</option><option>京广速递</option><option >日本邮政</option><option >筋斗云物流</option><option >捷克邮政</option><option >嘉里大通</option><option >加运美</option><option >快捷快递</option><option >跨越速运</option><option >克罗地亚邮政</option><option >联昊通</option><option >龙邦速递</option><option >黎巴嫩邮政</option><option >民航快递</option><option >秘鲁邮政</option><option >毛里求斯邮政</option><option >马耳他邮政</option><option >摩尔多瓦邮政</option><option >马其顿邮政</option><option >民邦快递</option><option id="szml56">明亮物流</option><option >挪威邮政</option><option >南非邮政</option><option >OnTrac</option><option >葡萄牙邮政</option><option >全峰快递</option><option >全一快递</option><option >如风达</option><option >申通快递</option><option selected="selected">顺丰速运</option><option >速尔快递</option><option >盛丰物流</option><option >圣安物流</option><option >盛辉物流</option><option >瑞士邮政</option><option >苏宁快递</option><option >斯洛伐克邮政</option><option >沙特邮政</option><option >斯洛文尼亚邮政</option><option >塞尔维亚邮政</option><option >天天快递</option><option >天地华宇</option><option >土耳其邮政</option><option >泰国邮政</option><option >TNT</option><option >UPS</option><option >USPS</option><option >万象物流</option><option >乌克兰邮政</option><option >万家物流</option><option >信丰物流</option><option >新邦物流</option><option >西班牙邮政</option><option >匈牙利邮政</option><option >圆通速递</option><option >韵达快递</option><option >优速物流</option><option >银捷速递</option><option >远成物流</option><option >运通中港快递</option><option >邮政国内小包</option><option >英国皇家邮政</option><option >意大利邮政</option><option >印度邮政</option><option >亚美尼亚邮政</option><option >越丰物流</option><option >亚风速递</option><option >邮政国际包裹</option><option >中通快递</option><option >宅急送</option><option >中铁物流</option><option >增益速递</option><option >中铁快运</option><option >芝麻开门</option><option >中国邮政</option><option >智利邮政</option><option >中速快递</option>
                      </select>
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">收件人姓名</label>
                    <div class="layui-input-block">
                      <input type="text" name="username" required  lay-verify="required" placeholder="请输入收货人姓名" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                  <div class="layui-form-item">
                    <label class="layui-form-label">收件人手机号码</label>
                    <div class="layui-input-block">
                      <input type="text" name="phonenumber" required  lay-verify="required" placeholder="请输入收件人手机号码" autocomplete="off" class="layui-input">
                    </div>
                  </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">录入人手机号码</label>
                        <div class="layui-input-block">
                            <input type="text" name="staffphone" placeholder="请输入录入人手机号码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                  <div class="layui-form-item">
                    <div class="layui-input-block">
                      <button class="layui-btn layui-btn-blue" lay-submit lay-filter="formDemo">立即提交</button>
                      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                  </div>
                </form>  
            </div>
        </div>
    </div>
    <script src="../../assets/layui.all.js"></script>
    <script src="../../js/bootstrap/jquery.min.js"></script>
    <script src="/js/layer/layer.js"></script>
    <script src="/admin/ckeckAllInputs.js"></script>
    <script>
      var form = layui.form, layer = layui.layer;
    </script>
    <script>
        $(function () {
            $("#form").submit(function () {
                // 获取输入内容
                var ex_num = $("input:eq(0)").val();
                var company = $("input:eq(1)").val();
                var username = $("input:eq(2)").val();
                var userphone = $("input:eq(3)").val();
                var staffphone = $("input:eq(4)").val();
                // 验证输入内容是否符合格式要求
                if (ifAddExpressInputChecked(ex_num,company,username,userphone)){
                    var windowID = layer.load(2);
                    // 向服务器发送消息
                    // $.getJson 或 $.post
                    var ex_info = {
                        ex_num:ex_num,
                        company:company,
                        username:username,
                        userphone:userphone
                    }
                    var bool01 = staffphone.length===0;
                    var bool02 = ifPhoneNumChecked(staffphone);
                    if (!bool01) {
                        if (!bool02){
                            layer.close(windowID);
                            layer.alert("录入人手机号格式有误，手机号必须为"+explainPhoneNum+"!",{icon:2,shade:0.05});
                        } else {
                            ex_info.staffphone = staffphone;
                        }
                    }
                    if (bool01 || (!bool01 && bool02)) {
                        $.post("/express/insert.do",ex_info,function (data) {
                            layer.close(windowID);
                            // 处理服务器返回的数据
                            if (data.status === 0) {
                                // 录入成功
                                // 将输入框清空(保留快递公司的默认值)
                                $("input").val("");
                                $("input:eq(1)").val("顺丰速运");
                                if (data.result == null) {
                                    layer.msg("录入成功",{icon:6,shade:0.05});
                                } else {
                                    layer.alert("录入成功，但" + data.result,{icon:0,shade:0.05});
                                }
                            } else {
                                // 录入失败
                                layer.msg("录入失败，请检查输入的信息！",{icon:2,shade:0.05});
                            }
                        },"JSON");
                    }
                }
                return false;
            });
        });
    </script>
</body>
</html>